package com.itheima.d4_collection_list;

import java.util.LinkedList;

public class LinkedListDemo {
    public static void main(String[] args) {
        // LinkedList独有功能
        // 栈
        LinkedList<String> stack = new LinkedList<>();
        stack.addFirst("第一颗子弹");
        stack.addFirst("第二颗子弹");
        stack.addFirst("第三颗子弹");
        stack.addFirst("第四颗子弹");
        System.out.println(stack);
        System.out.println("=====出栈=====");
        String s = stack.removeFirst();
        System.out.println(s);
        System.out.println(stack);
       stack.push("A");
       stack.pop();

        //队列(排队往后面拍)
        LinkedList<String> queue = new LinkedList<>();
        System.out.println("=====队列入队=====");
        queue.addLast("1号");
        queue.addLast("2号");
        queue.addLast("3号");
        System.out.println(queue);
        System.out.println("=====对列出队=====");
        String s1 = queue.removeFirst();
        System.out.println(s1);
        System.out.println(queue);
    }
}
